<!-- Include the Free Rich Text Editor Variables Page -->
<script>
function rteGetLink() {
  if (document.getElementById("url").value == ""){
	  alert('The URL field must be filled in.');
	  return false;
  }else{
    window.parent.document.execCommand("createlink", false, document.getElementById("url").value);
  	if (window.getSelection)
	  {
	    var selected_obj = window.parent.window.getSelection().focusNode;
  	}
	  else if (document.getSelection)
	  {
	  	var selected_obj = window.parent.document.getSelection().focusNode;
	  }
	  else if (document.selection)
	  {
		  var selected_obj = window.parent.document.selection.createRange().parentElement();
  	}
	  var current_tag = selected_obj;
  	var previous_tagName = selected_obj.tagName;
	  while(previous_tagName != "HTML"){
		  if(previous_tagName == "A"){
			  current_tag.href = document.getElementById("url").value;			  
			  break;
	  	}
		  current_tag = current_tag.parentNode;
			previous_tagName = current_tag.tagName;
    }
  }
  window.parent.closeDiv()
}
</script>
<fieldset>
<legend><b>Insert Link </b></legend>
<input id="url" type="text" size="32" /><br />
<input type="button" value="Insert" onClick="rteGetLink()" />
</fieldset>
